<template>
	<view class="department">
		<view class="department-list">
			<view class="department-list-item">
				<radio-group>
					<label class="radioBox" v-for="(item, index) in list" :key="item.id" @click="radioBoxClick(item)">
						<view>
							<radio :value="item.id" color="#007AFF" />
						</view>
						<image src="@/static/image/user.png"></image>
						<view>{{item.name}}</view>
					</label>
				</radio-group>			
			</view>
		</view>
		<view class="department-btn">
			<view><button type="default" @click="confirmDepartment">确定</button></view>
		</view>
	</view>
</template>

<script>
	import * as api from '@/utils/api.js';
	export default {
		data() {
			return {
				list: [],
				selectItem:{}
			}
		},
		onLoad(){
			this.getInit()
		},
		methods: {
			getInit(){
				
				api.getSectionList({orgId:""}).then(res=>{
					if(res.code == 0){
						this.list = res.data
					}
				})
			},
			radioBoxClick(item){
				this.selectItem = item
			},
			confirmDepartment(){
				let pages = getCurrentPages()
				let prePage = pages[pages.length - 2]
				prePage.setData({selectItem:this.selectItem})
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.department{
		padding: 10rpx 20rpx;
		background-color: #f6f6f6;
		height: 100vh;
		&-list{
			background-color: #fff;
			&-item{
				.radioBox{
					display: flex;
					align-items: center;
					padding: 20rpx 30rpx;
					border-bottom: 1rpx solid #f5f5f5;    
					image{
						width: 60rpx;
						height: 60rpx;
						border-radius: 30rpx;
						margin: 0 18rpx;
						background-color: #cccccc;
					}
				}
				.radioBox:last-child{
					border-bottom: none;
				}
			}
		}
		&-btn{
			width: 100%;
			position: fixed;
			left: 0;
			bottom: 10rpx;
			button{
				margin: 0 20rpx;
				background-color:#007AFF;
				color: #fff;
			}
		}
	}
</style>
